package com.weme.common.util

import java.net.HttpURLConnection
import java.net.URL

class StringExt {}


fun Int.isTypeImg() :Boolean{
    return  when(this){
        1,5,7 -> true
        else -> false
    }
}

fun String.getContentType(): String? {
    return try {
        val connection = URL(this).openConnection() as HttpURLConnection
        connection.setRequestProperty("User-Agent", "Mozilla/5.0")
        connection.setRequestProperty("Connection", "close")
        connection.connect()
        val contentType = connection.contentType
        connection.disconnect()
        contentType
    } catch (e: Exception) {
        e.printStackTrace()
        null
    }
}

fun Long.toFormattedString(): String {
    return "%,d".format(this)
}



